﻿using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;

namespace CommandLineConfigurationSample
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            try
            {
                CommandLineConfigurationSample(args);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.ReadKey();
        }

        private static void CommandLineConfigurationSample(string[] args)
        {
            var dict = new Dictionary<string, string>()
            {
                { "name","zj"},
                { "age","25"}
            };
            var builder = new ConfigurationBuilder()
                .AddInMemoryCollection(dict)
                .AddCommandLine(args);

            var config = builder.Build();

            Console.WriteLine($"{config["name"]}\t{config["age"]}");
        }
    }
}
